﻿namespace LastVersionOfIpPackage.GUI
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    /// <summary>
    /// histogram form
    /// </summary>
    public partial class Histogram : Form
    {
        /// <summary>
        /// result image
        /// </summary>
        private Bitmap img;

        /// <summary>
        /// Initializes a new instance of the <see cref="Histogram"/> class.
        /// </summary>
        public Histogram()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Sets the info need in core form.
        /// </summary>
        /// <param name="image">The image need make in it operation.</param>
        internal void SetInfo(Image image)
        {
            this.img = (Bitmap)image;
            this.CheckGray_CheckedChanged(null, null);
            this.CheckBlue_CheckedChanged(null, null);
            this.CheckGreen_CheckedChanged(null, null);
            this.CheckRed_CheckedChanged(null, null);
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckGray control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckGray_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
            if (this.GropBoxGray.Checked == true)
            {
                Bitmap result = ImageOperations.ImageEnchance.NewImageEnchanemwnt.DrawHistogram(Enum_needed.ColorNeed.Gray, this.img, 342);
                this.picHistogram.Image = result;
            }   
        }
            catch
            {
                MessageBox.Show("error happened");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckRed control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckRed_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
            if (this.GropBoxRed.Checked == true)
            {
                Bitmap result = ImageOperations.ImageEnchance.NewImageEnchanemwnt.DrawHistogram(Enum_needed.ColorNeed.Red, this.img, 342);
                this.picHistogram.Image = result;
            }
                        }
            catch
            {
                MessageBox.Show("error happened");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckGreen control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckGreen_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
            if (this.GropBoxGreen.Checked == true)
            {
               Bitmap result = ImageOperations.ImageEnchance.NewImageEnchanemwnt.DrawHistogram(Enum_needed.ColorNeed.Green, this.img, 342);
                this.picHistogram.Image = result;
            }
                        }
            catch
            {
                MessageBox.Show("error happened");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckBlue control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckBlue_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
            if (this.GropBoxBlue.Checked == true)
            {
                Bitmap result = ImageOperations.ImageEnchance.NewImageEnchanemwnt.DrawHistogram(Enum_needed.ColorNeed.Blue, this.img, 342);
                this.picHistogram.Image = result;
            }
            }
            catch
            {
                MessageBox.Show("error happened");
            }
        }
    }
}
